<?php
namespace app\mobile\controller;

use app\model\Complain; 

class WComplain extends Base
{
    public function W_complain()
    {
global $_P,$_G;
extract($this->Isworker());
$op = isset($_P['op'])?$_P['op']:'display';
$save = isset($_P['save']) ? $_P['save'] : false;
$is_refund = $myworker['level']==1 || $config['refund_limit_worker']!=1?true:false;
if ($op=='display'){
    $type = isset($_P['type'])?$_P['type']:'';
    $status = isset($_P['status'])?$_P['status']:0;
    $result = Complain::getDisplay($system,$themeid,$status,$type,$is_refund,false);
}elseif ($op=='reply'){
    $id = $_P['id'];
    $submit = $_P['submit'];
    $result = Complain::reply($system,$id,$submit,$myworker['username'],$is_refund);
}elseif($op == 'refund') {
    $opuser = $myworker['username'];
    $order_id = intval($_P['id']);
    $id = intval($_P['complanID']);
    if ($myworker['level']!=1 && $config['refund_limit_worker']!=2){
        return_msg('请联系超级管理员（老板或店长），进行退款操作');
    }
    $result = Complain::refund($order_id, $id, $themeid, $theme, $system, $config,$opuser);
}

if ($result['error']==1) {
    return_msg($result['msg']);
}else{
    $result['jubf'] = $jubf;
    $result['jishu'] = $jishu;
    if ($op=='display' || ($op == 'reply' && $save == false)) {
        extract($result);
        $return_clicent = get_defined_vars();
return view('/fcworker/fc_complain', $return_clicent);
    }else{
        return_msg($result, '', 'ajax');
    }
}

}
}